home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / uw_1.exe / UW_DEMO.C < prev    next >
Text File  |  1992-11-12  |  45KB  |  1,306 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /* UW_DEMO.C                                                                                                                            */
  4. /*                                                                                                                    Kevin Huck            */
  5. /*                                                                                                                    Boyd Gafford        */
  6. /*                                                                          */
  7. /*   This demo program will show you many of the capabilities of UltraWin   */
  8. /* version 2.50.  See the documentation for a complete function listing.    */
  9. /*                                                                          */
  10. /* NOTE:                                                                    */
  11. /*   This file has a tab size of 2, and can be compiled and linked under    */
  12. /*   small model.                                                           */
  13. /*                                                                          */
  14. /****************************************************************************/
  15. #include <stdlib.h>
  16. #include <dos.h>
  17. #include <stdio.h>
  18. #include <ctype.h>
  19. #include <conio.h>
  20. #include <time.h>
  21. #ifdef M_I86
  22.     #include <malloc.h>
  23. #else
  24.     #include <alloc.h>
  25. #endif
  26. #include "uw.h"
  27.  
  28. #define NUM_WINS 26
  29.  
  30. typedef struct fields_struct                        /* structure for field input to the    */
  31. {                                                                                /* order form function!                            */
  32.     int        num_fields;                                            /* total number of fields                        */
  33.     char    *input[10];                     /* strings for the result                        */
  34.     char    *mask[10];                      /* masks for display on the screen    */
  35.     char    *t[10];                                    /* templates for validation                    */
  36.     int        x[10];                          /* positions for the input                    */
  37.     int        y[10];
  38.     int        strip[10];                      /* strip masks on result?                        */
  39. } FIELDS;
  40.  
  41. /*----------------- global variables for the demo program ------------------*/
  42. WINDOW    Main_wn, Print_wn[2];
  43. WINDOW     Back_wn, *Back_wnp = &Back_wn;
  44. MENU        Top_menu, *Top_mnp = &Top_menu;
  45. MENU    Terminal_menu, Setup_menu, Window_menu, Files_menu;
  46. MENU        *Drop_mnps[4];
  47.  
  48. uchar     *Font8x14;
  49. PRINT     Printer1, Printer2;
  50. char         *Enque_strs[] =
  51.                 {
  52.                     "EnQue Software",
  53.                     "Route 1, Box 116C",
  54.                     "Pleasant Hill, MO, 64080",
  55.                     "24-Hour BBS (816) 353-0991",
  56.                     "Voice/Fax (816) 987-2515",
  57.                     "(Voice 5-10pm and weekends)"
  58.                 };
  59. char        Name[40], Address[40], City[30], State[10],
  60.                 Zip[10], Phone[20], Password[10];
  61. int         Wait_for_key = 1;
  62.  
  63.  
  64. /*------------------------ prototypes for the program ----------------------*/
  65. void wn_3d_plst( int c, int r, char *str, WINDOW *wnp );
  66. void wn_line_demo( void );
  67. void wn_entry_demo( void );
  68. void wn_color_demo( void );
  69. void wn_create_demo( void );
  70. void wn_scroll_demo( void );
  71. void wn_prompt( char *prompt, int mode );
  72. void wait( int mode );
  73. void title_screen( void );
  74. int  wn_menu_demo( void );
  75. int  background_func( void );
  76. void wn_change_att( uchar new_att, uchar old_att, WINDOW *wnp );
  77. void wn_font_demo( void );
  78. void wn_print_demo( void );
  79. void disp_print_stats( PRINT *p, int mode, WINDOW *wnp );
  80.  
  81.  
  82. /*********/
  83. /* ~main */
  84. /*       ********************************************************************/
  85. /****************************************************************************/
  86. void main()
  87. {
  88.     int r, end_flag = 0;
  89.     WINDOW *wnp;
  90.  
  91.     init_video(80, 25);
  92.     init_mouse();
  93.     init_clock(0x3333);
  94.     wnp = &Main_wn;
  95.     wn_create( 0, 3, V_cols-1, V_rows-1, NO_BDR, WN_NORMAL, wnp );
  96.     wn_color( CYAN, BLUE, wnp );
  97.     wn_bdr_color( YELLOW, BLUE, wnp );
  98.     wn_name("Main_wn", wnp);
  99.     link_window(wnp);
  100.     title_screen();
  101.     wn_plst( CENTERED, (V_rows / 2) - 1,
  102.          "Welcome to the UltraWin Library!", wnp );
  103.     if( Ega )
  104.         wn_plst( CENTERED, 3,
  105.              "UltraWin detects the presence of an EGA compatible board", wnp);
  106.     else if( Vga )
  107.         wn_plst( CENTERED, 3,
  108.              "UltraWin detects the presence of a VGA compatible board", wnp);
  109.     wait(0);
  110.  
  111.     wn_clear(wnp);
  112.     wn_color( BLUE, LIGHTGRAY, wnp );
  113.  
  114.     wn_plst(1, 0, "    Speed it one of many features incorporated into the UltraWin Library.     ", wnp );
  115.     wn_plst(1, 1, "   Here is a list of the main features, all of which will be demonstrated!    ", wnp );
  116.  
  117.     wn_color( YELLOW, BLUE, wnp );
  118.     wn_hline(2,SGL_BDR,wnp);
  119.     r = 3;
  120.     wn_plst(0, r++, "1) Complete range of windowing functions to dynamically create, update,", wnp );
  121.     wn_plst(0, r++, "   move, and destroy an unlimited number of windows.", wnp );
  122.     wn_color( WHITE, BLUE, wnp );
  123.     wn_plst(0, r++, "2) A Window Manager that will handle all the hard work when multiple", wnp );
  124.     wn_plst(0, r++, "   windows are on the screen.", wnp );
  125.     wn_color( YELLOW, BLUE, wnp );
  126.     wn_plst(0, r++, "3) Each window is fully buffered. Output to a window can take place at any", wnp );
  127.     wn_plst(0, r++, "   time, even if another window overlaps it.  This is perhaps, the", wnp );
  128.     wn_plst(0, r++, "   most impressive feature. Windows can scroll output even if overlapped!", wnp );
  129.     wn_color( WHITE, BLUE, wnp );
  130.     wn_plst(0, r++, "4) Powerful string and data entry capabilities.", wnp );
  131.     wn_color( YELLOW, BLUE, wnp );
  132.     wn_plst(0, r++, "5) Powerful menuing capability with full mouse support!", wnp );
  133.     wn_color( WHITE, BLUE, wnp );
  134.     wn_plst(0, r++, "6) The library supports virtually any video board, including 43/50", wnp );
  135.     wn_plst(0, r++, "   row EGA/VGA mode. It even works with non-standard modes i.e. 132*60.", wnp );
  136.     wn_color( YELLOW, BLUE, wnp );
  137.     wn_plst(0, r++, "7) UltraWin now works in EGA/VGA graphics mode and has user defined", wnp );
  138.     wn_plst(0, r++, "   font capability in both text and graphics modes!", wnp );
  139.     wn_color( WHITE, BLUE, wnp );
  140.     wn_plst(0, r++, "8) EGA/VGA palette control and blink enable/disable to allow all 16", wnp );
  141.     wn_plst(0, r++, "   background colors without foreground blinking.", wnp );
  142.     wn_color( YELLOW, BLUE, wnp );
  143.     wn_plst(0, r++, "9) UltraWin also has dynamic printer queues that can be either ram", wnp );
  144.     wn_plst(0, r++, "   or disked based and can print to multiple devices in the background!", wnp );
  145.     wn_hline(r,SGL_BDR,wnp);
  146.     wait(0);
  147.  
  148.     while( !end_flag )
  149.     {
  150.         wn_clear(wnp);
  151.         wn_color( BLUE, LIGHTGRAY, wnp );
  152.         r = 3;
  153.         wn_3d_plst(13, r++, "A) Color/Palette Control", wnp ), r++;
  154.         wn_3d_plst(13, r++, "B) Window Creation      ", wnp ), r++;
  155.         wn_3d_plst(13, r++, "C) Text Line Drawing    ", wnp ), r++;
  156.         wn_3d_plst(13, r++, "D) Window Scrolling     ", wnp ), r++;
  157.         wn_3d_plst(13, r++, "E) Data Entry           ", wnp ), r++;
  158.         r = 3;
  159.         wn_3d_plst(43, r++, "F) Drop-down Menus      ", wnp ), r++;
  160.         wn_3d_plst(43, r++, "G) EGA/VGA Text Fonts   ", wnp ), r++;
  161.         wn_3d_plst(43, r++, "H) Print Capabilities   ", wnp ), r++;
  162.         wn_3d_plst(43, r++, "I) All of the Above     ", wnp ), r++;
  163.         wn_color( RED, LIGHTGRAY, wnp );
  164.         wn_3d_plst(43, r++, "J) Quit Demo  <<Esc>>   ", wnp ), r++;
  165.         wn_color( BLUE, LIGHTGRAY, wnp );
  166.         if( Wait_for_key )
  167.             wn_3d_plst(13, r++, "K) Key press requirement between operations  : ON     ", wnp ), r++;
  168.         else
  169.             wn_3d_plst(13, r++, "K) Key press requirement between operations  : OFF    ", wnp ), r++;
  170.         r++;
  171.  
  172.         wn_prompt("Select desired demo to execute...", 1);
  173.         wn_color( LIGHTGRAY, BLUE, wnp );
  174.         switch( toupper(Event.key) )
  175.         {
  176.             case 'Q': case 'J':    case 27: end_flag = 1; break;
  177.  
  178.             case 'A': wn_color_demo();  break;
  179.             case 'B': wn_create_demo(); break;
  180.             case 'C': wn_line_demo();   break;
  181.             case 'D': wn_scroll_demo(); break;
  182.             case 'E': wn_entry_demo();  break;
  183.  
  184.             case 'F': wn_menu_demo();   break;
  185.             case 'G': wn_font_demo();   break;
  186.             case 'H': wn_print_demo();  break;
  187.  
  188.             case 'I':
  189.                 wn_color_demo();
  190.                 wn_create_demo();
  191.                 wn_line_demo();
  192.                 wn_scroll_demo();
  193.                 wn_entry_demo();
  194.                 wn_menu_demo();
  195.                 wn_font_demo();
  196.                 wn_print_demo();
  197.                 break;
  198.             case 'K': Wait_for_key = !Wait_for_key; break;
  199.         }
  200.     }
  201.     wn_destroy(wnp);
  202.     end_clock();
  203.     end_mouse();
  204.     end_video();
  205.     exit(0);
  206. }
  207. /*** end of main ***/
  208.  
  209. /***************/
  210. /* ~wn_3d_plst */
  211. /*             **************************************************************/
  212. /* This is specifically for the